package com.vueapi.controller.web;

import com.vueapi.domain.HjComment;
import com.vueapi.domain.vo.CommentsVo;
import com.vueapi.service.HjCommentService;
import com.vueapi.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @Classname WebCommentController
 * @Description TODO
 * @Created by 赵宏建
 * @Date 2023/8/2 15:00
 * @Version 1.0.0
 */
@RestController
@RequestMapping("/web/comment")
public class WebCommentController {

    @Autowired
    private HjCommentService commentService;

    @GetMapping("/getCommentsByBlogId")
    private ResultUtils getCommentsByBlogId(@RequestParam("blogId") Integer blogId){
        List<CommentsVo> commentsVo = commentService.getCommentsByBlogId(blogId);
        return ResultUtils.success(commentsVo);
    }


    @PostMapping("/add")
    public ResultUtils add(@RequestBody HjComment comment){
        boolean flag = commentService.add(comment);
        if(flag){
            return ResultUtils.success("添加评论成功，待用户审核通过后展示...");
        }else{
            return ResultUtils.success("评论失败...");
        }
    }


}
